from sqlalchemy.orm import Session

from app.admin_service.models.account import Account
from common.middleware.exceptions import AppException


def get_account_by_name(db: Session, account_name: str) -> Account:
    account = db.query(Account).filter(Account.account_name == account_name).first()
    if account is None:
        raise AppException(f"该账户{account_name}不存在")

    return account

